/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package visitors;

import entityclasses.Group;
import entityclasses.Person;
import java.util.Vector;

/**
 *
 * @author YCAN
 */
public class ShowPersonsWithGroupsVisitor implements IShowPersonsWithGroupsVisitor{
    
    public String visit(Group g)
    {
        String personList = "";

        Vector <Person> persons = new Vector<Person>();

        persons = g.getPersons();
        if(!g.getPersons().isEmpty())
        for(int i=0;i<persons.size();i++)
        {
            Person p = new Person();
            p = persons.elementAt(i);
            personList += p.toString() + "\n";
        }
        
        if(!g.getSubgroups().isEmpty())
            for(int i=0;i<g.getSubgroups().size();i++)
            {
                personList += "Alt Grup: "+g.getSubgroups().elementAt(i).getName() + "\n";
                personList += g.getSubgroups().elementAt(i).accept(this);
            }
        
        return personList;
    }
}
